package com.ruoyi.module.szLiveRoom.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.szLiveRoom.domain.SzLiveRoom;
import com.ruoyi.module.szLiveRoom.service.ISzLiveRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 直播间Controller
 * 
 * @author yqq
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/protal/module/szLiveRoom")
public class SzLiveRoomController extends BaseController
{
    @Autowired
    private ISzLiveRoomService szLiveRoomService;

    /**
     * 查询直播间列表
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzLiveRoom szLiveRoom)
    {
        startPage();
        List<SzLiveRoom> list = szLiveRoomService.selectSzLiveRoomList(szLiveRoom);
        return getDataTable(list);
    }

    /**
     * 导出直播间列表
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:export')")
    @Log(title = "直播间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SzLiveRoom szLiveRoom)
    {
        List<SzLiveRoom> list = szLiveRoomService.selectSzLiveRoomList(szLiveRoom);
        ExcelUtil<SzLiveRoom> util = new ExcelUtil<SzLiveRoom>(SzLiveRoom.class);
        return util.exportExcel(list, "直播间数据");
    }

    /**
     * 获取直播间详细信息
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(szLiveRoomService.selectSzLiveRoomById(id));
    }

    /**
     * 新增直播间
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:add')")
    @Log(title = "直播间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzLiveRoom szLiveRoom)
    {
        return toAjax(szLiveRoomService.insertSzLiveRoom(szLiveRoom));
    }

    /**
     * 修改直播间
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:edit')")
    @Log(title = "直播间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzLiveRoom szLiveRoom)
    {
        return toAjax(szLiveRoomService.updateSzLiveRoom(szLiveRoom));
    }

    /**
     * 根据streamName修改直播间
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:edit')")
    @Log(title = "直播间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult editSzLiveRoom(@RequestBody SzLiveRoom szLiveRoom)
    {
        return szLiveRoomService.editSzLiveRoom(szLiveRoom);
    }

    /**
     * 删除直播间
     */
    // @PreAuthorize("@ss.hasPermi('module:szLiveRoom:remove')")
    @Log(title = "直播间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szLiveRoomService.deleteSzLiveRoomByIds(ids));
    }

    /**
     * 获取直播推流地址
     */
    @GetMapping("/url")
    public AjaxResult getZbPushUrl()
    {
        return szLiveRoomService.getZbPushUrl();
    }

}
